import { httpTwo, http } from '@/utils/http/axios';
import qs from 'qs';
// 获取table
export function getBusinessList(params, query) {
  return httpTwo.request({
    url: '/merchant/list?' + qs.stringify(query),
    method: 'POST',
    params,
  });
}

// 新增商户
export function merchantInster(params) {
  return httpTwo.request({
    url: '/merchant',
    method: 'POST',
    params,
  });
}

// 修改商户
export function merchantUpdate(params) {
  return httpTwo.request({
    url: '/merchant',
    method: 'PUT',
    params,
  });
}

// 打包下载
export function downMerchantData(uuid) {
  return httpTwo.request({
    url: `/merchant/downMerchantData/${uuid}`,
    method: 'GET',
  });
}

/**
 * @description: 上传
 */
export function uploadBusinessFile(data: any) {
  const { file, url } = data;
  const formData = new FormData();
  formData.append('file', file);
  return http.request(
    {
      url,
      method: 'post',
      responseType: 'blob',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    },
    { breakTransformRequsetData: true },
  );
}
